<?php
if (!defined('BASEPATH')) exit('No direct script access allowed');

class Pay_m extends FOX_Model
{

	function __construct ()
	{
		parent::__construct();
        $this->config->load('userset');//用户积分
	}

    /**
     * @param $order_id
     * @return mixed
     * 查询单条
     */
    public function get_fox_orders_by_id($order_id){
        $query = $this->db
            ->select('*')
            ->get_where('fox_orders', array('order_id'=>$order_id));
        return $query->row_array();
    }

    /**
     * 根据订单号查询
     * @param $order_no
     * @return mixed
     */
    public function get_fox_orders_by_no($order_no){
        $query = $this->db
            ->select('*')
            ->get_where('fox_orders', array('order_no'=>$order_no));
        return $query->row_array();
    }
    /**
     * @param $order_id
     * @param $data
     * @return bool
     * 修改订单信息
     */
    public function sava_fox_orders($order_id,$data){

        $this->db->where('order_id',$order_id);
        $this->db->update('fox_orders', $data);
        return ($this->db->affected_rows() > 0) ? TRUE : FALSE;
    }

    /**
     * @param $data
     * @return bool
     * 新增订单
     */
    public function add_fox_orders($data){

        $this->db->insert('fox_orders',$data);
        if($this->db->affected_rows() > 0){
            return $this->db->insert_id();
        }else{
            return false;
        }
    }

    /**
     * @return mixed
     * 查询所有订单
     */
    public function get_all_fox_orders(){
        $this->db->select('*');
        $this->db->from('fox_orders');
        $this->db->join('fox_orders','fox_orders.order_no = fox_orders.order_no','left');
        $query = $this->db->get();
        if($query->num_rows() > 0){
            return $query->result_array();
        }
    }


}
